package com.bestcem.xm.txtanls.grpc.service.param.analysis;

import com.bestcem.xm.common.core.constant.RegTypes;
import com.bestcem.xm.txtanls.grpc.service.param.TextFieldParam;
import com.bestcem.xm.txtanls.service.impl.SurveyServiceImpl;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.util.List;

/**
 * 更新文本分析项目入参校验
 *
 * @author XiaoYunSong <ys.xiao@idiaoyan.com>
 * @version v1.0
 * @date 2021/5/10-15:21
 */
@AllArgsConstructor
@NoArgsConstructor
@Getter
@Setter
public class UpdateAnalysisProjectParam {

    /**
     * 用户id
     */
    @NotBlank(message = CreateAnalysisProjectParam.ErrorMessage.USER_ID_ERROR)
    @Pattern(regexp = RegTypes.OBJECT_ID, message = CreateAnalysisProjectParam.ErrorMessage.USER_ID_ERROR)
    private String userId;

    /**
     * 组织id
     */
    @NotBlank(message = CreateAnalysisProjectParam.ErrorMessage.ORG_ID_ERROR)
    @Pattern(regexp = RegTypes.OBJECT_ID, message = CreateAnalysisProjectParam.ErrorMessage.ORG_ID_ERROR)
    private String orgId;

    /**
     * 项目id
     */
    @NotBlank(message = "项目id错误")
    @Pattern(regexp = RegTypes.OBJECT_ID, message = "项目id错误")
    private String projectId;

    /**
     * 项目名称
     */
    @NotBlank(message = CreateAnalysisProjectParam.ErrorMessage.NAME_NULL_ERROR)
    @Size(max = SurveyServiceImpl.NAME_LENGTH, message = CreateAnalysisProjectParam.ErrorMessage.NAME_SIZE_ERROR)
    @Pattern(regexp = RegTypes.NAME, message = CreateAnalysisProjectParam.ErrorMessage.NAME_FORMAT_ERROR)
    private String name;

    /**
     * 数据表id
     */
    @NotBlank(message = CreateAnalysisProjectParam.ErrorMessage.TABLE_ID_ERROR)
    @Pattern(regexp = RegTypes.OBJECT_ID, message = CreateAnalysisProjectParam.ErrorMessage.TABLE_ID_ERROR)
    private String tableId;

    /**
     * 数据表名称
     */
    @NotBlank(message = CreateAnalysisProjectParam.ErrorMessage.TABLE_NAME_NULL_ERROR)
    private String tableName;

    /**
     * 训练字段列表
     */
    @Valid
    @NotEmpty(message = CreateAnalysisProjectParam.ErrorMessage.TEXT_FIELD_NULL_ERROR)
    private List<TextFieldParam> textFields;

    /**
     * 时间字段id
     */
    @NotBlank(message = CreateAnalysisProjectParam.ErrorMessage.TIME_FIELD_ID_ERROR)
    @Pattern(regexp = RegTypes.OBJECT_ID, message = CreateAnalysisProjectParam.ErrorMessage.TIME_FIELD_ID_ERROR)
    private String timeFieldId;

    /**
     * 时间字段名称
     */
    @NotBlank(message = CreateAnalysisProjectParam.ErrorMessage.TIME_FIELD_NAME_NULL_ERROR)
    private String timeFieldName;

    /**
     * 训练模型id
     */
    @JsonProperty(value = "model_id")
    private String modelId;
}
